using System;
using System.Windows.Forms;

namespace Curriculum.UI.Clases.ManejadorControles
{
	/// <summary>
	/// Summary description for ManejadorDate.
	/// </summary>
	public class ManejadorDate : ManejadorControles
	{
		public ManejadorDate()
		{
		}
		public override void Cargar(Control ctrl, object value)
		{
			if (value.ToString().Equals(string.Empty))
			{
				((DateTimePickerNullable)ctrl).Valor =  null;
			}
			else
			{
				((DateTimePickerNullable)ctrl).Valor = Convert.ToDateTime((string)value);
			}
		}
		public override void Inicializar(Control ctrl, object value)
		{
			DateTimePickerNullable control = ((DateTimePickerNullable)ctrl);

			control.Format =  DateTimePickerFormat.Custom;
			control.Valor = null;			
		}
		public override string GetValor(Control ctrl)
		{
			string valorSeleccionado = string.Empty;
			DateTimePickerNullable control = ((DateTimePickerNullable)ctrl);

			if (control.Valor != null)
			{
				valorSeleccionado = ((DateTime)control.Valor).ToShortDateString();
			}
			return valorSeleccionado;
		}

	}
}
